home *** CD-ROM | disk | FTP | other *** search
/ CD Exchange / CD Exchange - Volume 1.iso / graphics / utils / videotracker / develop / sourceaga / crunch.s < prev    next >
Text File  |  1994-02-10  |  9KB  |  492 lines

  1.  
  2.     opt    a+
  3.     opt    o+
  4.     opt    ow-
  5.  
  6.     section    1,code_c
  7.     
  8.     clr.l    d0
  9.     clr.l    d1
  10.     clr.l    d2
  11.     clr.l    d3
  12.     clr.l    d4
  13.     clr.l    d5
  14.     clr.l    d6
  15.     clr.l    d7
  16.     sub.l    a0,a0
  17.     sub.l    a1,a1
  18.     sub.l    a2,a2
  19.     sub.l    a3,a3
  20.     sub.l    a4,a4
  21.     sub.l    a5,a5
  22.     sub.l    a6,a6
  23.     
  24.     move.l    #raw,a0
  25.     move.l    #cru,a1    
  26.     move.l    #raw.e-raw,d0
  27.     bsr    crunch
  28.     move.l    d0,d1
  29.     move.l    #cru,d0
  30.     add.l    d0,d1
  31.     illegal    
  32.  
  33. ;    ;crunch routine
  34. ;    ;
  35. ;    ;a0 = pointer to uncrunched data
  36. ;    ;a1 = pointer to crunched data
  37. ;    ;d0 = length uncrunched data
  38. ;    ;
  39. ;    ;d0 returns  crunched data length
  40. ;
  41.  
  42.  
  43. offset =    $800
  44.  
  45. crunch
  46. Scrunch:
  47.     movem.l    d1-d7/a0-a6,-(sp)
  48.     move.l    a1,a2
  49.     move.l    a0,a1
  50.     add.l    d0,a1
  51.  
  52.     movem.l    a0-a2,-(sp)
  53.  
  54.     move.l    #'PVC!',(a2)+    ;set ascii info
  55.     move.l    d0,(a2)+        ;raw length
  56.     add.l    #4,a2        ;crunch length
  57.  
  58. ;    lea    start,a0    
  59. ;    lea    stop,a1    
  60. ;    lea    write,a2    
  61.  
  62.     moveq    #1,d2    
  63.     clr.w    d1    
  64.     clr.l    d7    
  65.  
  66. noteocrunch:
  67.     bsr.S    blkcrunch    
  68.     tst.b    d0
  69.     beq.S    crunched
  70.     addq.w    #1,d1
  71.     cmpi.w    #264,d1
  72.     bne.S    nojmp
  73.     bsr.w    dojmp
  74.  
  75. nojmp:
  76.  
  77. crunched:
  78.     move.w    a2,($dff180).l
  79.     cmp.l    a0,a1
  80.     bgt.S    noteocrunch
  81.     bsr.w    dojmp    
  82.     bsr.w    write1lwd    
  83.     move.l    d7,(a2)+    
  84.  
  85.     movem.l    (sp)+,a0-a1/a5
  86.  
  87. ;    lea    start,a0
  88. ;    lea    stop,a1
  89.  
  90.     move.l    a1,d2    
  91.     sub.l    a0,d2
  92.     move.l    d2,(a2)+        ;raw length
  93.     clr.l    d0
  94.     clr.l    d1
  95.     clr.l    d2
  96.     clr.l    d3
  97.     clr.l    d4
  98.     clr.l    d5
  99.     lea    cnt,a3
  100.     movem.w    (a3)+,d0-d5
  101.  
  102.     move.l    a2,a3
  103.     sub.l    a0,a3        ;
  104.  
  105.     sub.l    a5,a2
  106.     move.l    a2,d0        ;crunched data length
  107.     move.l    d0,8(a5)
  108.  
  109.     movem.l    (sp)+,d1-d7/a0-a6
  110.     rts
  111.  
  112. blkcrunch:
  113.     move.l    a0,a3
  114.     add.l    #offset,a3
  115.     cmp.l    a1,a3    
  116.     ble.S    nottop
  117.     move.l    a1,a3    
  118.  
  119. nottop:
  120.     moveq    #$1,d5    
  121.     move.l    a0,a5    
  122.     addq    #$1,a5
  123.  
  124. contcrunch:
  125.     move.b    (a0),d3    
  126.     move.b    $1(a0),d4
  127.  
  128. quickfind:
  129.     cmp.b    (a5)+,d3    
  130.     bne.S    contfind    
  131.     cmp.b    (a5),d4
  132.     beq.S    lenfind
  133.  
  134. contfind:
  135.     cmp.l    a5,a3
  136.     bgt.S    quickfind
  137.     bra.S    endquickfind
  138.  
  139. lenfind:
  140.     subq    #1,a5    
  141.     move.l    a0,a4    
  142.  
  143. scan:
  144.     move.b    (a4)+,d3    
  145.     cmp.b    (a5)+,d3
  146.     bne.S    endequ
  147.     cmp.l    a5,a3
  148.     bgt.S    scan
  149.  
  150. endequ:
  151.     move.l    a4,d3    
  152.     sub.l    a0,d3    
  153.     subq.l    #1,d3
  154.     cmp.l    d3,d5    
  155.     bge.S    nocrunch    
  156.     move.l    a5,d4    
  157.     sub.l    a0,d4    
  158.     sub.l    d3,d4
  159.     subq    #1,d4    
  160.     cmp.l    #$4,d3
  161.     ble.S    small
  162.     moveq    #$6,d6        
  163.     cmp.l    #$00000101,d3    
  164.     blt.S    oksafe
  165.     move.w    #$100,d3        
  166.  
  167. oksafe:
  168.     bra.S    cont1
  169.  
  170. small:
  171.     move.w    d3,d6    
  172.     subq.w    #$2,d6    
  173.     lsl.w    #1,d6
  174.  
  175. cont1:
  176.     lea    table,a6    
  177.     cmp.w    (a6,d6.w),d4    
  178.     bge.S    nocrunch        
  179.     move.l    d3,d5        
  180.     move.l    d4,maxsoffset
  181.     move.b    d6,tbloffset
  182.  
  183. nocrunch:
  184.     cmp.l    a5,a3    
  185.     bgt.S    contcrunch
  186.  
  187.  
  188. endquickfind:    
  189.     cmp.l    #$1,d5        
  190.     beq.S    nothingfound
  191.     bsr.S    dojmp    
  192.     move.b    tbloffset,d6
  193.     move.l    maxsoffset,d3
  194.     move.w    8(a6,d6.w),d0    
  195.     bsr.S    wd0bits        
  196.     move.w    16(a6,d6.w),d0    
  197.     beq.S    nolength        
  198.     move.l    d5,d3        
  199.     subq    #1,d3
  200.     bsr.S    wd0bits
  201.  
  202. nolength:
  203.     move.w    24(a6,d6.w),d0    
  204.     move.w    32(a6,d6.w),d3    
  205.     bsr.S    wd0bits        
  206.     addi.w    #$1,40(a6,d6.w)
  207.     addi.w    #$1,$dff188
  208.     add.l    d5,a0    
  209.     clr.b    d0    
  210.     rts
  211.  
  212. nothingfound:
  213.     move.b    (a0)+,d3
  214.     moveq    #$8,d0
  215.     bsr.S    wd0bits
  216.     moveq    #$1,d0
  217.     rts
  218. dojmp:
  219.     tst.w    d1
  220.     beq.S    skipjmp
  221.     move.w    d1,d3
  222.     clr.w    d1
  223.     cmp.w    #9,d3
  224.     bge.S    bigjmp
  225.     addq.w    #1,cntjmp
  226.     subq.w    #1,d3
  227.     moveq    #5,d0        
  228.     bra.S    wd0bits
  229.  
  230. skipjmp:
  231.     rts
  232.  
  233. bigjmp:
  234.     addq.w    #1,cntjmp+2
  235.     subi.w    #9,d3
  236.     or.w    #%0000011100000000,d3    
  237.     moveq    #11,d0            
  238.     bra.w    wd0bits
  239.  
  240. wd0bits:    
  241.     addi.w    #$1,$dff188
  242.     subq.w    #1,d0
  243.  
  244. copybits:
  245.     lsr.l    #1,d3    
  246.     roxl.l    #1,d2    
  247.     bcs.S    writelwd    
  248.     dbf    d0,copybits
  249.     rts
  250.  
  251. write1lwd:
  252.     clr.w    d0    
  253.  
  254. writelwd:
  255.     move.l    d2,(a2)+    
  256.     eor.l    d2,d7            
  257.     moveq    #1,d2            
  258.     dbf    d0,copybits            
  259.     rts
  260.  
  261.  
  262.     ;decrunch routine
  263.     ;
  264.     ;a0 = pointer to crunched data
  265.     ;a1 = pointer to uncrunched data
  266.  
  267.  
  268. Decrunch:
  269.     movem.l    d0-d7/a0-a6,-(sp)
  270.  
  271.     add.l    8(a0),a0    ;eind file
  272.  
  273. ;    lea    d_stop,a0    ; eind van data, kan relatief
  274. ;    lea    $60000,a1    ; destination
  275.  
  276.     move.l    -(a0),a2
  277.     add.l    a1,a2
  278.     move.l    -(a0),d5
  279.     move.l    -(a0),d0
  280.     eor.l    d0,d5
  281. Decrunch_a:    lsr.l    #1,d0
  282.     bne.s    Decrunch_b
  283.     bsr    Decrunch_m
  284. Decrunch_b:    bcs.s    Decrunch_i
  285.     moveq    #8,d1
  286.     moveq    #1,d3
  287.     lsr.l    #1,d0
  288.     bne.s    Decrunch_c
  289.     bsr    Decrunch_m
  290. Decrunch_c:    bcs.s    Decrunch_k
  291.     moveq    #3,d1
  292.     clr.w    d4
  293. Decrunch_d:    bsr    Decrunch_n
  294.     move.w    d2,d3
  295.     add.w    d4,d3
  296. Decrunch_e:    moveq    #7,d1
  297. Decrunch_f:    lsr.l    #1,d0
  298.     bne.s    Decrunch_g
  299.     bsr    Decrunch_m
  300. Decrunch_g:    roxl.l    #1,d2
  301.     dbra    d1,Decrunch_f
  302.  
  303.     move.b    d2,-(a2)
  304.     dbra    d3,Decrunch_e
  305.  
  306.     bra    Jump_a
  307.  
  308. Decrunch_h:    moveq    #8,d1
  309.     moveq    #8,d4
  310.     bra    Decrunch_d
  311.  
  312. Decrunch_i:    moveq    #2,d1
  313.     bsr    Decrunch_n
  314.     cmp.b    #2,d2
  315.     blt.s    Decrunch_j
  316.     cmp.b    #3,d2
  317.     beq.s    Decrunch_h
  318.     moveq    #8,d1
  319.     bsr    Decrunch_n
  320.     move.w    d2,d3
  321.     move.w    #12,d1
  322.     bra    Decrunch_k
  323.  
  324. Decrunch_j:    move.w    #9,d1
  325.     add.w    d2,d1
  326.     addq.w    #2,d2
  327.     move.w    d2,d3
  328. Decrunch_k:    bsr    Decrunch_n
  329. Decrunch_l:    subq.w    #1,a2
  330.     move.b    0(a2,d2.w),(a2)
  331.     dbra    d3,Decrunch_l
  332.  
  333. Jump_a:    cmp.l    a2,a1
  334.     blt    Decrunch_a
  335.  
  336. ;    tst.l    d5
  337. ;    bne.s    Error_a
  338.  
  339.     move.l    #0,d0        ;no errors!
  340.     movem.l    (sp)+,d0-d7/a0-a6
  341.     rts
  342.  
  343. ;    ;jmp    $30000        ; of iets anders
  344. ;    ;illegal    
  345. ;Error_a:    ;move.w    #$FFFF,d0
  346. ;Error_b:    ;move.w    d0,$DFF180
  347. ;    ;sub.l    #1,d0
  348. ;    ;bne.s    Error_b
  349. ;    move.l    #-1,d0        ;error!
  350. ;    rts
  351. ;    ;illegal        ; laat amiga vastlopen/return
  352.  
  353.  
  354. Decrunch_m:    move.l    -(a0),d0
  355.     eor.l    d0,d5
  356.     move    #$10,CCR
  357.     roxr.l    #1,d0
  358.     rts
  359.  
  360. Decrunch_n:    subq.w    #1,d1
  361.     clr.w    d2
  362. Decrunch_o:    lsr.l    #1,d0
  363.     bne.s    Decrunch_p
  364.     move.l    -(a0),d0
  365.     eor.l    d0,d5
  366.     move    #$10,CCR
  367.     roxr.l    #1,d0
  368. Decrunch_p:    roxl.l    #1,d2
  369.     dbra    d1,Decrunch_o
  370.     rts
  371.  
  372. table:
  373. offst:    dc.w    $0100,$0200,$0400,$1000
  374. blklnoff:    dc.w    $0008,$0009,$000a,$000c
  375. blklength:    dc.w    $0000,$0000,$0000,$0008
  376. blkcdlen:    dc.w    $0002,$0003,$0003,$0003
  377. blkcode:    dc.w    $0001,$0004,$0005,$0006
  378. cnt:    dc.w    $0,$0,$0,$0
  379. cntjmp:    dc.w    $0,$0
  380. maxsoffset:    dc.l    0
  381. tbloffset:    dc.l    0
  382.  
  383.     incdir    'w:'
  384.  
  385. ;raw    equ    $80000
  386. ;raw.e    equ    raw+366948
  387.  
  388.     cnop    0,2
  389. raw
  390. ;    incbin    'player/ProTracker'
  391. ;    incbin    'player/OctaMed'
  392.  
  393.  
  394. ;    incbin    'routineaga/ColorGrid.rot'
  395. ;    incbin    'routineaga/Equalizer.rot'
  396. ;    incbin    'routineaga/CopperMagnify4.rot'
  397.     incbin    'routineaga/CopperMagnify4AGA.rot'
  398. ;    incbin    'routineaga/CopperMagnify8.rot'
  399. ;    incbin    'routineaga/CopperPalette_16.rot'
  400. ;    incbin    'routineaga/CopperPicture.rot'
  401. ;    incbin    'routineaga/Landscape_L2.rot'
  402. ;    incbin    'routineaga/Landscape_L8.rot'
  403. ;    incbin    'routineaga/Object_H2.rot'
  404. ;    incbin    'routineaga/Object_H4.rot'
  405. ;    incbin    'routineaga/Object_H8.rot'
  406. ;    incbin    'routineaga/Object_L2.rot'
  407. ;    incbin    'routineaga/Object_L4.rot'
  408. ;    incbin    'routineaga/Object_L8.rot'
  409. ;    incbin    'routineaga/Object_L16.rot'
  410. ;    incbin    'routineaga/Object_L32.rot'
  411. ;    incbin    'routineaga/Object_L64.rot'
  412. ;    incbin    'routineaga/PaletteFade.rot'
  413. ;    incbin    'routineaga/PictureMove.rot'
  414. ;    incbin    'routineaga/Plasma.rot'
  415. ;    incbin    'routineaga/ScrollBig_L8.rot'
  416. ;    incbin    'routineaga/ScrollNTSC_H4.rot'
  417. ;    incbin    'routineaga/ScrollNTSC_L2.rot'
  418. ;    incbin    'routineaga/ScrollNTSC_L16.rot'
  419. ;    incbin    'routineaga/ScrollNTSC_L32.rot'
  420. ;    incbin    'routineaga/Scroll_H2.rot'
  421. ;    incbin    'routineaga/Scroll_H4.rot'
  422. ;    incbin    'routineaga/Scroll_L2.rot'
  423. ;    incbin    'routineaga/Scroll_L4.rot'
  424. ;    incbin    'routineaga/Scroll_L8.rot'
  425. ;    incbin    'routineaga/Scroll_L16.rot'
  426. ;    incbin    'routineaga/Scroll_L32.rot'
  427. ;    incbin    'routineaga/Stars.rot'
  428. ;    incbin    'routineaga/Tunnel.rot'
  429. ;    incbin    'routineaga/Vector_H2.rot'
  430. ;    incbin    'routineaga/Vector_H4.rot'
  431. ;    incbin    'routineaga/Vector_L2.rot'
  432. ;    incbin    'routineaga/Vector_L4.rot'
  433. ;    incbin    'routineaga/Vector_L8.rot'
  434. ;    incbin    'routineaga/Vector_L16.rot'
  435. ;    incbin    'routineaga/Vector_L32.rot'
  436. ;    incbin    'routineaga/VectorShade_L2.rot'
  437. ;    incbin    'routineaga/Wave.rot'
  438.  
  439.  
  440. ;    incbin    'routine/Equalizer.rot'
  441. ;    incbin    'routine/CopperMagnify4.rot'
  442. ;    incbin    'routine/CopperMagnify8.rot'
  443. ;    incbin    'routine/CopperPicture.rot'
  444. ;    incbin    'routine/PaletteFade.rot'
  445.  
  446. ;    incbin    'routine/ColorGrid.rot'
  447. ;    incbin    'routine/CopperPalette_16.rot'
  448. ;    incbin    'routine/Landscape_L2.rot'
  449. ;    incbin    'routine/Landscape_L4.rot'
  450. ;    incbin    'routine/Landscape_L8.rot'
  451. ;    incbin    'routine/Landscape_L16.rot'
  452. ;    incbin    'routine/Landscape_L32.rot'
  453. ;    incbin    'routine/Object_H2.rot'
  454. ;    incbin    'routine/Object_H4.rot'
  455. ;    incbin    'routine/Object_H8.rot'
  456. ;    incbin    'routine/Object_L2.rot'
  457. ;    incbin    'routine/Object_L4.rot'
  458. ;    incbin    'routine/Object_L8.rot'
  459. ;    incbin    'routine/Object_L16.rot'
  460. ;    incbin    'routine/Object_L32.rot'
  461. ;    incbin    'routine/Object_L64.rot'
  462. ;    incbin    'routine/Plasma.rot'
  463. ;    incbin    'routine/ScrollBig_L8.rot'
  464. ;    incbin    'routine/ScrollNTSC_H4.rot'
  465. ;    incbin    'routine/ScrollNTSC_L2.rot'
  466. ;    incbin    'routine/ScrollNTSC_L16.rot'
  467. ;    incbin    'routine/ScrollNTSC_L32.rot'
  468. ;    incbin    'routine/Scroll_H2.rot'
  469. ;    incbin    'routine/Scroll_H4.rot'
  470. ;    incbin    'routine/Scroll_L2.rot'
  471. ;    incbin    'routine/Scroll_L4.rot'
  472. ;    incbin    'routine/Scroll_L8.rot'
  473. ;    incbin    'routine/